package com.jinandi.app.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.jinandi.app.domain.Organization;

public interface OrganizationDao extends JpaSpecificationExecutor<Organization>, JpaRepository<Organization, Integer> , PagingAndSortingRepository<Organization, Integer>{

	/**
	 * <根据cn查询组织>
	 * @param cn
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-13 上午11:25:09
	 */
	@Query("select o from Organization o where o.cn = ?1")
	List<Organization> getOrgByCn(String cn);
	
	/**
	 * <根据父ID查询子>
	 * @param pid
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-13 上午11:25:28
	 */
	@Query("select o from Organization o where o.pid = ?1")
	List<Organization> getOrgChildrenByPid(Long pid);

	/**
	 * <获取根>
	 * @return
	 * @author CGC 
	 * 创建日期:2013-5-13 上午11:25:46
	 */
	@Query("select o from Organization o where o.cn ='root'")
	List<Organization> getOrgRoot();
}
